package cn.tedu.boot31.mapper;

import cn.tedu.boot31.entity.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface ProductMapper {
    @Insert("insert into product values(null,#{title},#{price},#{saleCount})")
    void insert(Product product);
    @Select("select * from product")
    //若格式与mysql数据名不符 需要声明 都为驼峰命名法 只不过mysql里面 用下划线代替
    @Result(column = "sale_count",property = "saleCount")
    List<Product> select();
    @Update("update product set title=#{title},price=#{price},sale_count=#{saleCount} where id=#{id}")
    void update(Product product);
    @Delete("delete from product where id=#{id}")
    void delete(int id);
}
